home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Singles Flirt Up Your Life! (German)
/
Singles Flirt Up Your Life.iso
/
data1.cab
/
Statemachine
/
computer.lua
< prev
next >
Wrap
Text File
|
2004-01-29
|
5KB
|
187 lines
-- computer state machine
beginStateMachine()
onEnter(function(msg)
setState("off");
end )
onMsg("buildMenu", function(msg)
if (repairMenu()) then return end
local character = getStateObjectFromID(msg.sender);
-- build the pie menu
clearPieMenu();
local button ;
-- button = addPieMenuButton("pm_chat", "chat");
-- button.addDescription(ACTIVITY, "chatComputer");
--
-- button = addPieMenuButton("pm_play", "play");
-- button.addDescription(ACTIVITY, "playComputer");
--local isUsing = isUser(character, this, PC_ACTIVITIES);
if (not isUser(character, this, {"playComputer"})) then
button = addPieMenuButton("pm_play", "use", "play");
button.addDescription(ACTIVITY, "playComputer");
--if (isUsing) then button.addDescription(DONTQUEUE, "true"); end;
end
if (not isUser(character, this, {"chatComputer"})) then
button = addPieMenuButton("pm_chat", "use", "chat");
button.addDescription(ACTIVITY, "chatComputer");
--if (isUsing) then button.addDescription(DONTQUEUE, "true"); end;
end
end )
-- chat on the computer
onMsg("use", function(msg)
-- get the game object server
local gameObjectServer = getGameObjectServer();
-- get character who initiated this action
local character = getStateObjectFromID(msg.sender);
-- get the walk state object
local wso = character.walkSO;
-- which program to use
local program = msg.data;
-- if (isUser(character, this, PC_ACTIVITIES)) then
-- --character allready using this PC: send switch msg
-- print(" PC onMsg use is User" .. wso.getStateMachine().getName() .. "." .. wso.getState());
-- sendMsg("switch", wso, msg.data);
-- else
-- check if computer is on table and retrieve the chair
local chair = getChairForItemOnTable(this);
if (chair) then
-- get the chairs action point
local actionPoint = character.getClosestFreeActionPoint(character, chair, {"sit1", "sit2"} );
if (actionPoint) then
if (wso.walkToActionPoint(actionPoint)) then
-- create state machine contexts
local wsoContext = StateMachineContext();
-- store the action point
wsoContext.storeData("actionPointName", actionPoint.getName());
wsoContext.storeData("program", program);
wso.queueStateMachine("computerChar.sitDown", this, wsoContext);
else
print("no path found");
instantAbort(character, EMOTICON_NOPATH, "emoThink")
end
else
print("no action point found");
instantAbort(character, EMOTICON_CANNOT, "emoThink")
end
else
print("no chair found");
instantAbort(character, EMOTICON_NOSEAT, "emoThink")
end
-- end
end )
-- -- play on the computer
-- onMsg("play", function(msg)
-- -- get the game object server
-- local gameObjectServer = getGameObjectServer();
-- -- get character who initiated this action
-- local character = getStateObjectFromID(msg.sender);
-- -- check if computer is on table and retrieve the chair
-- local chair = getChairForItemOnTable(this);
-- if (chair) then
-- -- get the chairs action point
-- local actionPoint = character.getClosestFreeActionPoint(character, chair, {"sit1", "sit2"});
-- -- get the walk state object
-- local wso = character.walkSO;
-- if (actionPoint) then
-- -- create state machine contexts
-- local wsoContext = StateMachineContext();
-- -- store the action point
-- wsoContext.storeData("actionPointName", actionPoint.getName());
-- if (wso.walkToActionPoint(actionPoint)) then
-- wso.queueStateMachine("computerChar.sitDownPlay", this, wsoContext);
-- else
-- print("no path found");
-- instantAbort(character, EMOTICON_NOPATH, "emoThink")
-- end
-- else
-- print("no action point found");
-- instantAbort(character, EMOTICON_CANNOT, "emoThink")
-- end
-- else
-- print("no chair found");
-- instantAbort(character, EMOTICON_NOSEAT, "emoThink")
-- end
-- end )
state("off")
onEnter(function(msg)
print("Comp off enter ----------------------------");
replaceTexture("tvOff", "tvOff");
--stopAllSounds();
end )
onExit(function(msg)
playSound("computerStartup");
end )
state("play")
onEnter(function(msg)
print("Comp play enter ----------------------------");
sendMsgThis("startAnim");
end )
onExit(function(msg)
end )
onMsg("startAnim", function(msg)
startAnim({"pcGame1", "pcGame2", "pcGame3", "pcGame4", "pcGame3", "pcGame2"});
end )
onMsg("showPic", function(msg)
replaceTexture("tvOff", msg.data);
end )
state("chat")
onEnter(function(msg)
print("Comp chat enter ----------------------------");
sendMsgThis("startAnim");
end )
onExit(function(msg)
end )
onMsg("startAnim", function(msg)
startAnim({"pcChat1", "pcChat2", "pcChat3", "pcChat4"}, 3000);
end )
onMsg("showPic", function(msg)
replaceTexture("tvOff", msg.data);
end )
endStateMachine()